﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Dao;
using System.Data;
using Utils;

namespace Website.uc
{
    public partial class ucAdminItems : System.Web.UI.UserControl
    {
        ItemsDao itemDao = new ItemsDao();
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack){
                LoadAllItems();
            }
        }

        private void LoadAllItems()
        {
            DataTable tb = itemDao.getAllItems();
            gridItems.DataSource = tb;
            gridItems.DataBind();
        }

        protected void gridItems_SelectedIndexChanging(object sender, GridViewSelectEventArgs e)
        {
            string id = Utility.GetValueGridView(gridItems , 0 , e);
            Session["item"] = id;
            Response.Redirect("PageAdminSaveItems.aspx");
        }

        protected void gridItems_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {

        }
    }
}